package com.liudadan.controller;

import com.liudadan.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

@Controller
@ResponseBody
@RequestMapping("json")
public class JsonController {
    //String
    @PostMapping("data1")
    public String data1(@RequestBody String json){
        System.out.println("JsonController.data1");
        System.out.println("json = " + json);
        return json;
    }

    @PostMapping("data2")
    public String data2(@RequestBody Map<String,Object> json){
        System.out.println("JsonController.data2");
        System.out.println("json = " + json);
        return  json.toString();
    }
    //实体类
    @PostMapping("data3")
    public String data3(@RequestBody User user){
        System.out.println("JsonController.data3");
        System.out.println("user = " + user);
        return user.toString();
    }

}
